package com.welink.cmp.adapter.api.metadata;

import com.welink.base.catchlog.CatchAndLog;
import com.welink.cmp.dto.metadata.eip.CreateEipAddCmd;
import com.welink.cmp.dto.metadata.eip.SetupEipUpdateCmd;
import com.welink.cmp.meatdata.service.EipAppService;
import com.welink.common.dto.Response;
import com.welink.common.dto.SingleResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * EIP生命周期管理API
 *
 * @author yanwei li create  2024-05-22 11:20
 */
@RestController("/api/eip")
@CatchAndLog
class EipLifeCycleServiceApi {

    @Autowired
    private EipAppService eipAppService;

    /**
     * 创建EIP
     *
     * @param addCmd 创建EIP指令
     * @return VPC ID
     */
    @PostMapping("/addEip")
    public SingleResponse<Long> addEip(@RequestBody CreateEipAddCmd addCmd) {
        final Long id = eipAppService.addEip(addCmd);
        return SingleResponse.of(id);
    }
    /**
     * 配置EIP
     *
     * @param updCmd 创建EIP指令
     * @return VPC ID
     */
    @PostMapping("/modify")
    public Response configEip(@RequestBody SetupEipUpdateCmd updCmd) {
        final Boolean b = eipAppService.updateEip(updCmd);
        return Response.buildSuccess();
    }

}
